<!DOCTYPE html>
<html lang="en">
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath(); 
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<head>
	<title>Moto - 列表</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,minimum-scale=1,maximum-scale=1,user-scalable=no">
    <script type="text/javascript" src="../js/jquery-1.9.0.min.js"></script>
    <style type="text/css">
        .body_div{padding-top:2.2em;
            text-align:center;}
        .table-detail{
            text-align:center;
            border: 1px solid rgb(228,228,228);
        }
        th{
            text-align:center;
            background-color: rgb(230,230,230);
            border-bottom: 1px solid rgb(228,228,228);
            font-weight: bold;
            color:rgb(90,90,90);
            padding: 8px;
        }
        td{
            text-align:center;
            border: 1px solid rgb(228,228,228);
            color:rgb(56,56,56);
            font-size:15px;
            padding: 8px;
            line-height: 1.5em;
            height:1.5em;
        }
        td input{
            width:90%;
        }
        ul li{
            border:solid 1px rgb(233,233,233) ;
            list-style :none;
            float:left;
            padding:8px 15px;
            line-height: 1.5em;
            height:1.5em;
        }
        a {
            text-decoration: none;
        }
        .imgsc {width:25px;height:25px;}
    </style>
</head>

<body>
<form id="motoForm" name="motoForm" action="<%=basePath%>moto/list" method="post" >

<div class="body_div" >
    <table class="table-detail" style="overflow:hidden;margin:0 auto; width:1131px;" >
        <tr>
            <th>名称</th>
            <td>
                <input type="text" name="moto_name" id="moto_name" value="${SRModel.moto_name}"/>
            </td>
            <th>类型</th>
            <td>
               <input type="text" name="moto_type" id="moto_type" value="${SRModel.moto_type}"/>
            </td>
            <th>品牌</th>
            <td>
                <input type="text" name="moto_brand" id="moto_brand" value="${SRModel.moto_brand}"/>
            </td>
            <td>
              <a href="javascript:searchData('1')">查询</a>
            </td>
            <td>
                <a href="javascript:clearFrom()">清空</a>
            </td>
            <td>
                <a href="javascript:goAdd()">新增</a>
            </td>
        </tr>
    </table>
    <table class="table-detail" align="center" style="overflow:hidden;margin:0 auto; width:1131px;" >
        <tr>
            <th style="">序号</th>
            <th style="">名称</th>
            <th style="">类型</th>
            <th style="">品牌</th>
            <th style="">Url</th>
            <th style="">缩略图</th>
            <th>操作</th>
        </tr>
        <c:forEach items="${srm}" var="var" varStatus="s">
        <tr>
            <td>${(s.index+1) * SRModel.currentPage}</td>
            <td>${var.moto_name}</td>
            <td>${var.moto_type}</td>
            <td>${var.moto_brand} </td>
            <td><a href="${var.moto_url}"  target="_blank"> ${var.moto_url}</a> </td>
            <td>
                <c:if test="${var.img_url !=null and var.img_url!=''}">
                    <a href="<%=basePath%>${var.img_url}" target="_blank">
                        <img class="imgsc" id="imgPath1" src="<%=basePath%>${var.img_url}"/>
                    </a>
                </c:if>
            </td>
            <td>
                <a href="<%=basePath%>moto/edit?sid=${var.sid}" target="_blank" >编辑</a>
                <a href="javascript:ajaxUpFmotoStatus('${var.sid}');"  >删除</a>
            </td>
        </tr>
        </c:forEach>
    </table>
</div>
<div style="overflow:hidden;margin:0 auto; width:1131px;">
    <input type="hidden" id="currentPage" name="currentPage" value="${SRModel.currentPage}">

    <ul style="float:right;">
        <li>当前第 ${SRModel.currentPage} 页/共 ${SRModel.totalPage} 页 每页
            <input type="text" id="showCount" name="showCount" value="${SRModel.showCount}" style="width:50px;"/> 条/共 ${SRModel.totalCount} 条</li>
        <li><a href="javascript:searchData(1);">首页</a></li>
        <li><a href="javascript:searchData(${SRModel.currentPage-1});">上一页</a></li>
        <li><a href="javascript:searchData(${SRModel.currentPage+1});">下一页</a></li>
        <li><a href="javascript:searchData(${SRModel.totalPage});">末页</a></li>
        <li>
            跳到第&nbsp;<input type="text" id="inputPage" name="inputPage" value="" style="width:50px;"/>
                  &nbsp;<a href="javascript:goPageIndex();">Go 确定</a>
        </li>
    </ul>
</div>
</form>
</body>
<script type="text/javascript">
    window.onload=function(){

    };

    function goPageIndex(){
        var inputPage = document.getElementById("inputPage").value;
        if(isNaN(inputPage) || inputPage==""){
            document.getElementById("inputPage").focus();
            alert("请输入数字!");
            return ;
        }
        if(inputPage>Number("${SRModel.totalPage}")){
            inputPage = ${SRModel.totalPage};
        }
        searchData(inputPage);
    }

    function searchData(currentPage){
        if(currentPage>Number("${SRModel.totalPage}")){
            currentPage = ${SRModel.totalPage};
        }
        document.getElementById("currentPage").value = currentPage;
        document.motoForm.submit();
    }


    function clearFrom(){
        document.getElementById("moto_type").value="";
        document.getElementById("moto_brand").value="";
        document.getElementById("moto_name").value="";
    }

    function goAdd(){
        var url = "<%=basePath%>moto/edit";
        window.open(url);
        //winopen(url,800,600);
    }

    function winopen(url,width,height){
        var left = (screen.width/2) - width/2;
        var top = (screen.height/2) - height/2;
        var styleStr = 'toolbar=no,location=no,directories=auto,status=no,menubar=no,scrollbars=yes,resizable=yes,z-look=no,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;
        window.open(url,"", styleStr);
    }

    function ajaxUpFmotoStatus(tid){
        if(!confirm("确定删除?")){
            return ;
        }

        $.ajax({
            type:"POST",
            url:"<%=basePath%>ajax/moto/status",
            data:{
                'sid' : tid,
                'status' : "0",
                'tm':new Date().getTime()
            },
            dataType:'json',
            cache: false,
            async: false,
            success: function(data){
                if(data.code==0){
                    window.location.reload();
                }
            }, error: function(XMLHttpRequest, textStatus, errorThrown) {
                alert(XMLHttpRequest.status+" | "+XMLHttpRequest.readyState+"|"+textStatus);
            }
        });
    }



</script>
</html> 

